/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */

#ifndef __M2_SKELETON_LOAD_IMPL_H__
#define __M2_SKELETON_LOAD_IMPL_H__

#include "OgreMatrix4.h"
#include "OgreSkeleton.h"
#include "OgreBone.h"

#include "M2Model.h"
#include "M2AnimData.h"

namespace PQGameCore
{
	class M2SkeletonBone 
	{
	};

	/** Internal class that used to load m2 skeleton data into Ogre mesh.
        @remarks
			This class shouldn't used by user,just an implementation of m2 skeleton loader.
    */
	class M2SkeletonLoadImpl
	{
	public:
		typedef std::vector<Ogre::Bone*> BoneList;
		M2SkeletonLoadImpl(Ogre::Skeleton *skeleton);
		void load(std::string path);
	private:
		void initM2Bones();
		void initM2Bone(int index);
		void initBoneTree(int index);
		void initM2Animations();
		void initBoneAnim(Ogre::Animation* anim,int animIndex,int boneIndex);//create specific bone animation
		
	private:
		Ogre::Skeleton *_skeleton;
		std::string _path;

		M2Model* _m2Model;
		M2File* _m2File;
		M2AnimFileList _animFileList;

		int _boneCount;
		M2Bone* _m2Bones;
		BoneList _boneList;

		int _animCount;
		M2Animation* _m2Anims;
		unsigned int* _globalSeqs;//
	};
}

#endif
